Compiling on Windows

Prerequisities

Visual Studio 2017

Git

CMake

POedit

NSIS

7-Zip

Get the wxWidgets 3.1.2 sources and build them

cd C:\Users\myname\Sources
git clone -b v3.1.2 https://github.com/wxWidgets/wxWidgets
cd wxWidgets
git submodule init
git submodule update

cd build\msw
nmake /f makefile.vc BUILD=release SHARED=1 CXXFLAGS=/D_USING_V141_SDK71_ CFLAGS=/D_USING_V141_SDK71_ LDFLAGS=/SUBSYSTEM:WINDOWS,5.01
nmake /f makefile.vc BUILD=debug SHARED=1 CXXFLAGS=/D_USING_V141_SDK71_ CFLAGS=/D_USING_V141_SDK71_ LDFLAGS=/SUBSYSTEM:WINDOWS,5.01

Alternatives:

Getting and building OpenCPN source

Get the OpenCPN sources

In the open x86 Native Tools Command Prompt for VS 2017 execute the following commands:

cd \Users\myname\Sources
git clone https://github.com/OpenCPN/OpenCPN

Get prebuilt Windows dependencies

Building OpenCPN

cd C:\Users\myname\Sources\OpenCPN
mkdir build
cd build
cmake -G "Visual Studio 15 2017" -T v141_xp ..
cmake --build .
cmake --build . --config release
cmake --build . --config release --target package

Alternatives:

Setup Copyfiles.bat - Last step to Debug

Copyfiles.bat is a useful single batch file to copy all the needed files to the various directories. This batch file does not execute any cmake commands.

Now Opencpn should be ready to debug.

BatchUTILS

BatchUTILS is another alternative that is a more complete set of batch files to assist building OpenCPN. Osetup.bat is intended to be modified by an individual user based on their own system. Git clone https://github.com/transmitterdan/BatchUTILS to your github directory, next to the OpenCPN local repository. Discussion about the use and development of BatchUtils

It’s nearly impossible to guess all the possible wxWidgets versions someone might have on their system. Also, other tools sometimes change paths as new versions are released. So it is expected that each user will customize Osetup.bat. The latest of Transmitter Dan's batchutils is in git. If you want to use some other environment variable other than WXDIR that is ok. The Cmake tool will accept a number of possible environment names as the root of the wxWidgets toolkit.

First Run

1. First try doing Release or RelWithDebInfo to avoid issues using Debug because of missing wxWidgets debug .dlls. 2. Do not use the “All Build” target. Use the “opencpn” target. 3. Right click on “opencpn” target, and select “Set as StartUp Project” 4. Build the target “opencpn”. Should be able to debug this now. 5. If you get a popup similar to “this DLL can't be found; wxmsw312ud_gl_vc_custom.dll 6. You will need to rebuild wxWidgets in Debug mode if you want to run the OCPN Debug build. Not difficult. See the Wiki page. 7. You can also get useful debugging from the “RelWithDebInfo” build.